// custom class
var WTPUtil = function() {
	this.ciStr = "<WTPInfo>\n";

	this.addKeyVal = function (key, val){
		this.ciStr += "<" + key + ">" + val + "</" + key + ">\n";
	};

	this.contentInfoString = function() {
		return this.ciStr + "</WTPInfo>";
	};

	this.testFunc = function(index) {
		this.ciStr += "<test>test</test>";
	};
}
// end of custom

title = document.querySelector("h3.title").textContent;
writer = document.querySelector("span.theme a").textContent;
date = document.querySelector("span.date").textContent;
body = document.querySelector("div.subContents").textContent;

if(!title) {
	title = document.querySelector("a.skinArticleTitle").textContent;
	writer = document.querySelctor("span.articleTheme").textContent;
	date = document.querySelctor("span.articleTime").textContent;
	body = document.querySelctor("div.articleText").textContent;
}

var wu = new WTPUtil();
wu.addKeyVal("_TITLE", title);
wu.addKeyVal("_DATE", date);
wu.addKeyVal("_WRITER", writer);
wu.addKeyVal("_BODY", body);

comments = document.querySelectorAll("div.each_comment");
for (var i=0;i<comments.length;i++) {
	var ele = comments[i];
	commenter = ele.querySelector("p.label").textContent;
	comment = ele.querySelector("p.comment_body").textContent;
	commentDate = ele.querySelector("div.comment_footer span.comment_date").textContent;
	wu.addKeyVal("_COMMENT", commenter + "|" + commentDate + "|" + comment);
}

tmpDiv = document.createElement("div");
tmpDiv.innerHTML = wu.contentInfoString();
document.documentElement.appendChild(tmpDiv);

console.log("==============================================================");
console.log(wu.contentInfoString());
console.log("==============================================================");
